
package cn.sccl.common.scheduler.enums;

/**
 * @author _minus
 * @create 2017-10-01 18:06
 */
public enum JobStateEnum {
    INIT_STATS("初始化任务","init_stats",9999),
    TASK_ERROR("执行失败","task_error",-1),
    TASK_WAITING("未执行","task_waiting",0),
    TASK_RUNNING("正在执行","task_running",1),
    TASK_SUCCESS("执行成功","task_success",2),

    STATE_NONE("禁用","NONE",0),
    STATE_NORMAL("启用","NORMAL",1),
    STATE_PAUSED ("暂停","PAUSED",2),
    STATE_COMPLETE("完成","COMPLETE",3),
    STATE_ERROR ("错误","ERROR",4),
    STATE_BLOCKED ("封锁","BLOCKED",5);



    private JobStateEnum(String name , String type , Integer code){
        this.name = name ;
        this.type = type ;

        this.code = code ;
    }

    private String name ;
    private String type;

    private Integer code ;

    /**
     * 根据type 获取到 JobStateEnum
     * @param type
     * @return
     */
    public static JobStateEnum getJobStateEnumByType(String type){
        for (JobStateEnum jobStateEnum : JobStateEnum.values()) {
            if (jobStateEnum.getType().equals(type)){
                return jobStateEnum ;
            }
        }
        return null;
    }


    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getType() {
        return type;
    }

    public void setType(String type) {
        this.type = type;
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }
}